package cn.edu.scau.cmi.chensicheng.multiton;

import java.util.ArrayList;

public class Marshal {
	private static ArrayList<Marshal> marshals = new ArrayList<Marshal>();
	private String name;

	private Marshal(String name) {
		this.name = name;
	}

	public static boolean addInstance(String name) {
		if (marshals.size() < 10) {
			marshals.add(new Marshal(name));
			return true;
		} else {
			return false;
		}
	}
	
	public static String print() {
		String message="";
		for(Marshal marshal:marshals)
			message+=marshal.getName()+'\n';
		return message;
	}
	
	public static void clear() {
		marshals.clear();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
